home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-03 / pbwiz16.zip / ARCVIEW.BAS < prev    next >
BASIC Source File  |  1993-02-24  |  3KB  |  103 lines

  1. '   +----------------------------------------------------------------------+
  2. '   |                                                                      |
  3. '   |         PBWIZ  Copyright (c) 1991-1993  Thomas G. Hanlin III         |
  4. '   |                                                                      |
  5. '   |                      PowerBASIC Wizard's Library                     |
  6. '   |                                                                      |
  7. '   +----------------------------------------------------------------------+
  8.  
  9. ' This is another simple demo of the PBWiz routines.  It allows you to
  10. ' view the files in an archive (.ARC, .ARJ, .LZH, .PAK, .ZIP, or .ZOO).
  11.  
  12. ' Syntax:
  13. '   ARCVIEW arcname[.ext] [/V]
  14.  
  15. ' The file extension for the archive is optional, although you may want to
  16. ' specify it if there is a possibility that you have two archives of the
  17. ' same name but different extensions (e.g., FOO.ARJ and FOO.ZIP).  The /V
  18. ' option allows you to specify a full listing-- without it, you will get
  19. ' a "wide format" display containing just the file names in the archive.
  20.  
  21.    $DIM ARRAY
  22.  
  23.    DECLARE SUB CloseA ()
  24.    DECLARE SUB FindFirstA (STRING, STRING, INTEGER)
  25.    DECLARE SUB FindNextA (INTEGER)
  26.    DECLARE FUNCTION GetDateA$ ()
  27.    DECLARE SUB GetSizeA (LONG, LONG)
  28.    DECLARE FUNCTION GetTimeA$ ()
  29.  
  30.    $LINK "pbwiz.pbl"
  31.  
  32.    DEFINT A-Z
  33.  
  34.    Cmd$ = LTRIM$(RTRIM$(UCASE$(COMMAND$)))
  35.    IF INSTR(Cmd$, "/?") THEN
  36.       PRINT "ARCVIEW: View Archive Demo for PBWiz by Thomas G. Hanlin III"
  37.       PRINT
  38.       PRINT "Syntax:"
  39.       PRINT "  ARCVIEW arcname[.ext] [/V]
  40.       PRINT
  41.       PRINT "Use /V for a full listing, as opposed to just a list of the files contained"
  42.       PRINT "in the archive.  ARCVIEW currently supports ARC, ARJ, LZH, PAK, ZIP, and ZOO."
  43.       END
  44.    END IF
  45.    tmp = INSTR(Cmd$, "/V")
  46.    IF tmp THEN
  47.       FullView = -1
  48.       Cmd$ = LTRIM$(RTRIM$(LEFT$(Cmd$, tmp - 1) + MID$(Cmd$, tmp + 2)))
  49.    END IF
  50.    IF LEN(Cmd$) THEN
  51.       Arc$ = Cmd$
  52.    ELSE
  53.       PRINT "Please specify the name of an archive."
  54.       END
  55.    END IF
  56.  
  57.    CALL FindFirstA (Arc$, "*.*", ErrCode)
  58.    IF ErrCode THEN
  59.       PRINT "Unable to open archive "; CHR$(34); Arc$; CHR$(34)
  60.       END
  61.    END IF
  62.  
  63.    IF FullView THEN
  64.       PRINT "Filename       Date       Time    CRC        Curr. Size    Orig. Size"
  65.       PRINT "------------   --------   -----   --------   -----------   -----------"
  66.    END IF
  67.  
  68.    DO
  69.       FileName$ = GetNameA$
  70.       IF FullView THEN
  71.          PRINT FileName$; SPACE$(15 - LEN(FileName$));
  72.          DateSt$ = LEFT$(GetDateA$, 6) + RIGHT$(GetDateA$, 2)
  73.          TimeSt$ = LEFT$(GetTimeA$, 5)
  74.          PRINT DateSt$; "   "; TimeSt$; "   "; GetCRCA$;
  75.          CALL GetSizeA (OriginalSize&, CurrentSize&)
  76.          CALL PrintComma (CurrentSize&, 14)
  77.          CALL PrintComma (OriginalSize&, 14)
  78.          PRINT
  79.       ELSE
  80.          PRINT FileName$; SPACE$(16 - LEN(FileName$));
  81.       END IF
  82.       CALL FindNextA (ErrCode)
  83.    LOOP UNTIL ErrCode
  84.  
  85.    CALL CloseA
  86.  
  87.    IF NOT FullView THEN PRINT
  88.  
  89. SUB PrintComma (Number&, FieldLen)
  90.    N$ = LTRIM$(STR$(Number&))
  91.    R$ = ""
  92.    DO WHILE LEN(N$) > 3
  93.       R$ = RIGHT$(N$, 3) + "," + R$
  94.       N$ = LEFT$(N$, LEN(N$) - 3)
  95.    LOOP
  96.    IF LEN(N$) THEN R$ = N$ + "," + R$
  97.    IF RIGHT$(R$, 1) = "," THEN R$ = LEFT$(R$, LEN(R$) - 1)
  98.    IF LEN(R$) < FieldLen THEN
  99.       R$ = SPACE$(FieldLen - LEN(R$)) + R$
  100.    END IF
  101.    PRINT R$;
  102. END SUB
  103.